export const ossUrl = (url:string):string=>{
    return (import.meta.env.VITE_OSS_URL as string) + url
}
export const publicUrl = (url:string):string=>{
  // return "https://kanfangtuan.haofangtiao.com" + url
    return (import.meta.env.VITE_PUBLIC_URL as string) + url
}


// 节流
type ThrottleFunction<T extends (...args: any[]) => any> = (fn: Function, delay: number) => (...args: Parameters<T>) => void;
/**
 * @desciption 节流
 * @param { Function } fn 函数
 * @param { number } delay 延迟时间
 * **/
export const throttle: ThrottleFunction<(...args: any[]) => void> = (fn: Function, dealy: number = 1000) => {
  let lastTime = 0;
  return (...args) => {
    const currentTime = Date.now();
    if (currentTime - lastTime >= dealy) {
      fn.apply(this, args)
      lastTime = currentTime
    }
  }
}